﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<VietPay.KooBoo.Business.Models.BatchListViewModel>" %>
<%@ Import Namespace="VietPay.KooBoo.Business.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   Phân phối hàng hóa
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<% using (Html.BeginForm("BatchVMSCreateGood", "Batch", FormMethod.Post))
       {%>
<div>
<h2>Phân phối hàng hóa</h2>
</div>
<div>
<h2>Thông tin đơn vị nhận</h2>
    
    <%= Html.ValidationSummary(true)%>
    <table width="100%">
        <tbody>
            <% if (Model.DistributorListView != null & Model.DistributorListView.DistributorList.Count() > 0)
               { %>
            <tr>
                <td class="key">
                    Đơn vị nhận (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.DropDownList("Distributor", new SelectList(Model.DistributorListView.DistributorList, "DistributorID", "DistributorName"), "-- Danh mục Distributor --",null)%>
                </td>
                <td class="key">
                    Tên đơn vị (<font color="red">*</font>)
                </td>
                <td align="left">
                    <%= Html.TextBoxFor(model => model.ThisPageItemCount, new { style = "width: 256px;", maxlength = 256 })%>
                </td>
            </tr>
            <%} %>
            <tr>
                <td class="key">
                    Số CMTND (<font color="red">*</font>)
                </td>
                <td align="left">
                    <%= Html.TextBoxFor(model => model.ThisPageItemCount, new { style = "width: 256px;", maxlength = 256 })%>
                </td>
                <td class="key">
                    Địa chỉ
                </td>
                <td align="left">
                    <%= Html.TextBoxFor(model => model.ThisPageItemCount, new { style = "width: 256px;", maxlength = 256 })%>
                </td>
            </tr>
        </tbody>
    </table>
    

</div>
<div>
<h2>Thông tin lô hàng</h2>

    <%= Html.ValidationSummary(true)%>
    <table width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Ngày nhập (<font color="red">*</font>)
                </td>
                <td align="left">
                    <%= Html.TextBoxFor(model=>model.ThisPageItemCount, new { style = "width: 256px;", maxlength = 256 })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Mã lô
                </td>
                <td align="left">
                    <%= Html.TextBoxFor(model => model.ThisPageItemCount, new { style = "width: 256px;", maxlength = 256 })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Loại sản phẩm
                </td>
                <td align="left">
                    <%=Html.DropDownList("Category", new SelectList((List<CategoryViewModel>)ViewData["CategoryList"], "CategoryID", "CategoryName"), "-- Chọn loại sản phẩm --", null)%>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div>
<h2>Chi tiết lô hàng</h2>
    <%--<%int counter = 0; %>--%>

    <%= Html.Telerik().Grid(Model.BatchDetailList)
        .Name("BatchGrid")
        .ToolBar(commands =>
                 {
                     commands.Insert();
                     //commands.SubmitChanges();
                 })
        .DataKeys(datekeys=>datekeys.Add(key=>key.ID))
        .Editable(editing => editing.Mode(GridEditMode.InCell))
        .DataBinding(dataBinding => dataBinding
                    .Ajax()
                    //Home.Index renders the grid initially
<<<<<<< .mine
                    .Select("_AjaxBinding", "Batch")
=======
                    .Select("BatchVMSCreateGood", "Batch")
                    //Home.Insert inserts a new data record
                    .Insert("Insert", "Home")
>>>>>>> .r5
                    //Home.Update updates an existing data record
<<<<<<< .mine
                               .Update("_SaveBatchEditing", "Batch")
=======
                    .Update("TestCreate", "Batch")
                    //Home.Delete deletes an existing data record
                    .Delete("Delete", "Home")
>>>>>>> .r5
                )
        .Columns(columns =>
        {
            
            columns.ForeignKey(o => o.ProductID, (IEnumerable)ViewData["Product"],
                   "ProductID", "ProductName").Width(300).Title("Mệnh giá/gói sản phẩm");
            columns.Bound(o => o.Quantity).Title("Số lượng");
            columns.Bound(o => o.Price).Title("Giá xuất");
            columns.Bound(o => o.Total).Title("Thành tiền");
            columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Delete();
                }).Title("Action");
        })
        //.ClientEvents(events => events.OnEdit("onEdit"))
        .Pageable()
        .Sortable()
        .KeyboardNavigation()
        .Resizable(resizing => resizing.Columns(true))
        .NoRecordsTemplate("Không có dữ liệu")
        .Footer(false)
    %>

</div>
<div>
    <% Html.BeginForm("TestCreate", "Batch", FormMethod.Post); %>
        <input type="submit" value="Xác nhận" />
    <%Html.EndForm(); %>

<input type="submit" value="Bỏ qua" onclick='performSubmit()' />
<button class='t-button' onclick='performSubmit()'>Submit changes</button>

<button class='t-button' onclick='performSubmit()'>Xác nhận</button>

</div>
<<<<<<< .mine
<%}
    %>
<script type="text/javascript">
    function BatchSave() {
        var grid = $('#BatchGrid').data('tGrid');

        alert(grid.data);

       grid.submitChanges();
   }

   function performSubmit() {
       var grid = $('#BatchGrid').data('tGrid');
       //alert(grid);
       grid.submitChanges();
   };

</script>

=======

<script type="text/javascript">
    function performSubmit() {
        var grid = $('#BatchGrid').data('tGrid');
        grid.submitChanges();
    };
</script>

>>>>>>> .r5
</asp:Content>



